<?php
class BaseAction extends Action {
    public $mall_order='';  //用户商城订单
	 public $apilogin;
	 public $user;
	  public $uid;
	function mod_init(){
	$this->user_id=0;
		$this->mall_order=D('Mall_order');
		$this->apilogin=D('Apilogin');
		$this->user=D('User');
		/*$mall=D('Mall')->select();
	 //  print_r($mall);
		$malltype=D('type')->field('id,title,sort,sys')->order('sys DESC')->where("tag='mall'")->select();
		foreach($malltype as $ke =>$va){   
     		  $i=0; 
		    foreach($mall as $k=>$v){  
			if($v['cid']==$va['id']){
			     $malltype[$ke]['mid'][$i]=$v;
				  unset($mall[$k]);
			     $i++;
			   } 
			} 
		// print_r(count($mall).'----');
				
		}
		//print_r($malltype);
	//	$this->mall=$malltype; */
		}
	function _initialize() {		
		
		$this->mod_init();		
	    $this->uid=empty($_COOKIE['userid'])?0:$_COOKIE['userid'];
		$this->assign(uid,$this->uid);
  if(isset($_COOKIE['userid']))
	  { 
	  //$user->field('id')->where("ddusername='".$data['ddusername']."'")->select()
	    $this->assign(user,$this->user->where("id=".$_COOKIE['userid'])->select());
	  }		
	
		

	}
	
	public function randomFloat($min = 0, $max = 1) {  
    return $min + mt_rand() / mt_getrandmax() * ($max - $min);  
                } 
   function getdbleveldata($id) {
             
   return  $this->object2array(json_decode(preg_replace('/[\n\r\t]/', ' ', preg_replace('/\s(?=\s)/', '', trim(file_get_contents('public/mall/'.$id.'.html'))))));
   
		
   }
   public function object2array($object) {  
    if (is_object($object)) {  
        foreach ($object as $key => $value) {  
            $array[$key] = $value;  
        }  
    }  
    else {  
        $array = $object;  
    }  
    return $array;  
} 
}